<template>
  <div class="content-box">
    <nav-title title="档案信息" />
    <edit-line label="机构联系人" v-model="outf.cOutfMgtAttn"></edit-line>
    <edit-line label="联系电话" v-model="outf.cOutfMgtTel"></edit-line>
    <edit-line label="管理机构" v-model="outf.cOutfNowMgtOrg"></edit-line>
    <edit-line label="档案所在地" v-model="outf.cOutfNowPlace"></edit-line>
    <edit-line label="报到证主体公司" v-model="outf.cRegCertComp"></edit-line>
    <edit-line label="档案原所在地" v-model="outf.cOutfOrigPlace"></edit-line>
    <edit-date-line label="调入时间" v-model="outf.cOutfXferInDt"></edit-date-line>
    <edit-date-line label="调出时间" v-model="outf.cOutfXferOutDt"></edit-date-line>
    <div class="bsbtn" @click="save">保存</div>
  </div>

</template>

<script>
import { Datetime, Group, PopupRadio } from 'vux'
import EditLine from '../../../../components/basic/EditLine'
import EditDateLine from '../../../../components/basic/EditDateLine'
import { getOutf, saveOutf} from '../../../../api/api'
import { json2Form } from '../../../../util/http'

export default {

  name: 'input-information',
  components: {
    EditLine,EditDateLine
  },
  mounted(){
    // if(this.$store.state.hid){
    //   this.outf.rsHireId = this.$store.state.hid
    // }
  },
  data() {
    return {
      outf:{}
    }
  },
  created() {
    this.getOutf()
  },
  methods: {
    save() {
      var that = this
      console.log(this.outf)
      if(this.outf.cOutfXferInDt && this.outf.cOutfXferOutDt && this.outf.cOutfXferInDt > this.outf.cOutfXferOutDt) {
        this.$vux.alert.show({
            title: '提示',
            content: '请填写正确的档案调动时间',
          })
          return;
      }
      if(!this.outf.cOutfMgtAttn 
        && !this.outf.cOutfMgtTel
        && !this.outf.cOutfNowMgtOrg
        && !this.outf.cOutfNowPlace
        && !this.outf.cRegCertComp
        && !this.outf.cOutfOrigPlace
        && !this.outf.cOutfXferInDt
        && !this.outf.cOutfXferOutDt) {
        this.$vux.alert.show({
            title: '提示',
            content: '请至少填写其中一个项目',
          })
          return;
      }
      saveOutf(json2Form(that.outf)).then(res => {
        if(res && res.retCode === '000000' ){
          //保存成功
          this.$vux.alert.show({
            title: '提示',
            content: '保存成功',
            onHide () {
              that.$router.push('/informationCollection/userInfo');
            }
          })

        }else{
          // 显示
          this.$vux.alert.show({
            title: '提示',
            content: res.retMsg
          })
        }
      }).catch (res=>{
        this.$vux.alert.show({
          title: '警告',
          content: '网络异常，请稍后重试'
        })
      })
    },

    getOutf() {
      if(this.$route.params.outf){
        this.outf = this.$route.params.outf
      }
      console.log(this.$route.params)
      CommonUtil.fillDateEmpty(this.outf, ['cOutfXferInDt','cOutfXferOutDt'])
    }
  },
  watch: {
    '$route': 'getBsif'
  }
}
</script>
<style type="text/scss" lang="scss">
  @import "./editinfo";
</style>
